package id.co.rho.scoring.cid.shared.model;

import java.util.List;

import id.co.rho.scoring.cid.changecontrol.entitychange.UpdateEntityChange;
import id.co.rho.scoring.cid.client.model.ChangeTrackingModel;

public class LitigationModel extends ChangeTrackingModel{
	private static final long serialVersionUID = 1L;
	public static final String ID = "id";
    public static final String BASE_ENTITY = "baseEntity";
	public static final String LITIGATION_REC_NO_NAME = "litigationRecNo";
	public static final String LITIGATION_REC_DATE = "litigationRecDate";
	
	public LitigationModel() {
		super();
	}
	
	public LitigationModel(UpdateEntityChange change) {
		super(change);
	}
	
	public static List<LitigationModel> applyChanges(List<LitigationModel> modelList, List<UpdateEntityChange> uecList){
    	Long idModel, idUec;
    	LitigationModel newModel;
    	if(uecList!=null){
	    	for (UpdateEntityChange change : uecList) {
				idUec = (Long) change.getEntityId();
				if(idUec!=null){
			    	for (LitigationModel model : modelList) {
			    		idModel = (Long) model.get(LitigationModel.ID);    		
		    			if(idModel.compareTo(idUec)==0){
		    				model.setChange(change);
		    			}
		    		}
				}else{
					newModel = new LitigationModel(change);
					modelList.add(newModel);
				}
	    	}
    	}
    	return modelList;
    }
}
